using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UwinEducation.Domain.Entities
{

    /// <summary>
    /// 角色权限关联实体
    /// </summary>
    [Table("sys_role_permissions")]
    public class RolePermission : EntityBase
    {
        /// <summary>
        /// 角色权限ID
        /// </summary>
        public Guid Id { get; private set; }

        /// <summary>
        /// 角色ID
        /// </summary>
        public Guid RoleId { get; set; }

        /// <summary>
        /// 权限ID
        /// </summary>
        public Guid PermissionId { get; set; }
        /// <summary>
        /// 菜单Code
        /// </summary>
        public string PermissionCode { get; set; }

        /// <summary>
        /// 角色导航属性
        /// </summary>
        //public Role Role { get; private set; }

        /// <summary>
        /// 权限导航属性
        /// </summary>
        //public Permission Permission { get; private set; }

        private RolePermission() { }

        /// <summary>
        /// 创建角色权限关联
        /// </summary>
        /// <param name="roleId">角色ID</param>
        /// <param name="permissionId">权限ID</param>
        /// <param name="permissionCode">权限Code</param>
        /// <returns>角色权限关联实体</returns>
        public static RolePermission Create(Guid roleId, Guid permissionId, string permissionCode)
        {
            return new RolePermission
            {
                Id = Guid.NewGuid(),
                RoleId = roleId,
                PermissionId = permissionId,
                PermissionCode = permissionCode,
                CreatedAt = DateTime.Now
            };
        }
    }
}